package com.rc.saas.mini.vo.elec;

import com.rc.saas.mini.common.constant.WebConstant;
import com.rc.saas.mini.model.elec.ElecStation;
import com.rc.saas.mini.model.elec.ElecStationPrice;
import com.rc.saas.mini.search.TenantDiscountSearch;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author wangzhengwei
 * @create 2021/4/19
 */
public class ElecStationExtInfo extends ElecStation {
    private Long rowid;//行号
    private String stationTypeName;
    private String tenantName;
    private BigDecimal pvPrice;//宣传价格(搜索页面用)
    private String elecType;  //电桩类型(电桩类型(1:单直流，2：单交流，3：双直流，4，双交流，5，交直流一体，) 新标准)(直流快交流慢)
    private String isSpecialParking;       //是否专用车位（0：否，1：是）
    private String printStatus;//打印机状态（1正常，2缺纸，3故障）
    private String isFreeParking;       //是否免费停车（0：否，1：是）

    private Integer quickPileNum;//快充枪总个数

    private Integer slowPileNum;//慢充枪总个数

    private Integer usableQuickNum;//可用直流 快充

    private Integer usableSlowNum;//可用交流 慢充

    private String stationSource; //充电站来源,0平台内 1第三方互联互通充电站,默认0（原来原openOperatorType）

    private List<String> photos;//照片集合

    //private List <String> traits;//特点集合
    private String area;

    private BigDecimal distance;//距离

    private BigDecimal elecPrice;

    private BigDecimal servicePrice;

    private String isCollection;
    private String servicePhone;
    // 0否 1是  显示优惠价格开关
    private Integer isDisplay = 0;
    //0 否 1是 是否saas内运营商
    private Integer isSaas = 0;

    private String collect;

    private String usingDate;

    //超级会员
    private TenantDiscountSearch memberSuperLevel;
    //会员等级
    private TenantDiscountSearch memberLevelRecord;
    //桩群优惠
    private TenantDiscountSearch stationDiscount;
    //企业桩群优惠
    private TenantDiscountSearch enterpriseDiscount;
    //个人钱包最佳优惠(从以上优惠中选择)
    private TenantDiscountSearch bestDiscount;
    //企业钱包最佳优惠(从以上优惠中选择)
    private TenantDiscountSearch enterpriseBestDiscount;
    private ElecStationPrice currentElecStationPrice;

    public ElecStationPrice getCurrentElecStationPrice() {
        return currentElecStationPrice;
    }

    public void setCurrentElecStationPrice(ElecStationPrice currentElecStationPrice) {
        this.currentElecStationPrice = currentElecStationPrice;
    }

    public List<String> getTraits() {
        ArrayList<String> list = new ArrayList<>();
        if (WebConstant.CON0.equals(getBizType())) {
            if ((0 == getIsSaas())) {
                list.add("自营");
            }
        }
        //if (WebConstant.CON0.equals(getIs24h())) {
        //    //list.add("24小时营业");
        //}
        if (WebConstant.CON1.equals(getIsFreeParking())) {
            list.add("免费停车");
        }
        if (WebConstant.CON0.equals(getIsSpecialParking())) {
            list.add("专用车位");
        }
        return list;
    }

    public String getUsingDate() {
        return usingDate;
    }

    public void setUsingDate(String usingDate) {
        this.usingDate = usingDate;
    }

    public ElecStationExtInfo(ElecStation elecStation)  {
        BeanUtils.copyProperties(elecStation, this);
        this.setElecStationId(elecStation.getElecStationId());
        this.setTenantCode(elecStation.getTenantCode());
        this.setTenantOperatorCode(elecStation.getTenantOperatorCode());
        this.setHlhtTenantCode(elecStation.getHlhtTenantCode());
        this.setHlhtOperatorId(elecStation.getHlhtOperatorId());
        this.setHlhtStationNo(elecStation.getHlhtStationNo());
        this.setStationNo(elecStation.getStationNo());
        this.setStationName(elecStation.getStationName());
        this.setStationType(elecStation.getStationType());
        this.setCountryCode(elecStation.getCountryCode());
        this.setProvinceId(elecStation.getProvinceId());
        this.setCityId(elecStation.getCityId());
        this.setAreaId(elecStation.getAreaId());
        this.setAddress(elecStation.getAddress());
        this.setBizType(elecStation.getBizType());
        //this.setIs24h(elecStation.getIs24h());
        this.setBizStartTime(elecStation.getBizStartTime());
        this.setBizEndTime(elecStation.getBizEndTime());
        this.setElecType(elecStation.getElecType());
        this.setElecServerDomain(elecStation.getElecServerDomain());
        this.setLatitude(elecStation.getLatitude());
        this.setLongitude(elecStation.getLongitude());
        this.setStationStar(elecStation.getStationStar());

        this.setHint(elecStation.getHint());
        this.setStationContract(elecStation.getStationContract());
        this.setServicePhone(elecStation.getServicePhone());
        this.setIsFreeParking(elecStation.getIsFreeParking());
        this.setIsSpecialParking(elecStation.getIsSpecialParking());
        this.setParkingRemark(elecStation.getParkingRemark());
        this.setStationImg1(elecStation.getStationImg1());
        this.setStationImg2(elecStation.getStationImg2());
        this.setStationImg3(elecStation.getStationImg3());
        this.setStationImg4(elecStation.getStationImg4());
        this.setStationImg5(elecStation.getStationImg5());
        this.setStationSource(elecStation.getStationSource());
        this.setOperateStatus(elecStation.getOperateStatus());
        this.setCreatedBy(elecStation.getCreatedBy());
        this.setCreatedTime(elecStation.getCreatedTime());
        this.setLastUpdatedBy(elecStation.getLastUpdatedBy());
        this.setLastUpdatedTime(elecStation.getLastUpdatedTime());
        this.setDistance(elecStation.getDistance());
        ArrayList<String> imgUrls = new ArrayList<>();

        if (elecStation.getStationImg1() != null && !"".equals(elecStation.getStationImg1().trim())) {
            imgUrls.add(elecStation.getStationImg1());
        }
        if (elecStation.getStationImg2() != null && !"".equals(elecStation.getStationImg2().trim())) {
            imgUrls.add(elecStation.getStationImg2());
        }
        if (elecStation.getStationImg3() != null && !"".equals(elecStation.getStationImg3().trim())) {
            imgUrls.add(elecStation.getStationImg3());
        }
        if (elecStation.getStationImg4() != null && !"".equals(elecStation.getStationImg4().trim())) {
            imgUrls.add(elecStation.getStationImg4());
        }
        if (elecStation.getStationImg5() != null && !"".equals(elecStation.getStationImg5().trim())) {
            imgUrls.add(elecStation.getStationImg5());
        }
        this.photos = imgUrls;

        if (elecStation.getParkingPrice() != null) {
            this.setParkingPrice(elecStation.getParkingPrice());
        } else {
            this.setParkingPrice(BigDecimal.ZERO);
        }

        if (elecStation.getBizStartTime() != null && elecStation.getBizEndTime() != null) {
            SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
            try {
                this.usingDate=changeEndTime(format.parse(elecStation.getBizStartTime()))
                        +"-"+changeEndTime(format.parse(elecStation.getBizEndTime()));
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }

    }


    public static String changeEndTime(Date date) {
        //瑞晨是闭区间，蚂蚁需要到右半开区间
        SimpleDateFormat format = new SimpleDateFormat("HH:mm");
        String endTime = format.format(date);
        if ("59".equals(format.format(date).substring(3))) {
            int endTimeHH = Integer.valueOf(format.format(date).substring(0, 2)) + 1;
            if (endTimeHH <= 9) {
                endTime = "0" + endTimeHH + ":00";
            } else {
                endTime = endTimeHH + ":00";
            }

        }
        if (!"00".equals(format.format(date).substring(3)) && !"59".equals(format.format(date).substring(3))) {
            int endTimemm = Integer.valueOf(format.format(date).substring(3)) + 1;
            if (endTimemm <= 9) {
                endTime = format.format(date).substring(0, 2) + ":0" + endTimemm;
            } else {
                endTime = format.format(date).substring(0, 2) + ":" + endTimemm;
            }
        }
        return endTime;
    }

    public Long getRowid() {
        return rowid;
    }

    public void setRowid(Long rowid) {
        this.rowid = rowid;
    }

    public String getStationTypeName() {
        return stationTypeName;
    }

    public void setStationTypeName(String stationTypeName) {
        this.stationTypeName = stationTypeName;
    }

    public String getTenantName() {
        return tenantName;
    }

    public void setTenantName(String tenantName) {
        this.tenantName = tenantName;
    }

    public BigDecimal getPvPrice() {
        return pvPrice;
    }

    public void setPvPrice(BigDecimal pvPrice) {
        this.pvPrice = pvPrice;
    }

    @Override
    public String getElecType() {
        return elecType;
    }

    @Override
    public void setElecType(String elecType) {
        this.elecType = elecType;
    }

    @Override
    public String getIsSpecialParking() {
        return isSpecialParking;
    }

    @Override
    public void setIsSpecialParking(String isSpecialParking) {
        this.isSpecialParking = isSpecialParking;
    }

    public String getPrintStatus() {
        return printStatus;
    }

    public void setPrintStatus(String printStatus) {
        this.printStatus = printStatus;
    }

    @Override
    public String getIsFreeParking() {
        return isFreeParking;
    }

    @Override
    public void setIsFreeParking(String isFreeParking) {
        this.isFreeParking = isFreeParking;
    }

    @Override
    public Integer getQuickPileNum() {
        return quickPileNum;
    }

    @Override
    public void setQuickPileNum(Integer quickPileNum) {
        this.quickPileNum = quickPileNum;
    }

    public Integer getSlowPileNum() {
        return slowPileNum;
    }

    public void setSlowPileNum(Integer slowPileNum) {
        this.slowPileNum = slowPileNum;
    }

    @Override
    public Integer getUsableQuickNum() {
        return usableQuickNum;
    }

    public void setUsableQuickNum(Integer usableQuickNum) {
        this.usableQuickNum = usableQuickNum;
    }

    public Integer getUsableSlowNum() {
        return usableSlowNum;
    }

    public void setUsableSlowNum(Integer usableSlowNum) {
        this.usableSlowNum = usableSlowNum;
    }

    @Override
    public String getStationSource() {
        return stationSource;
    }

    @Override
    public void setStationSource(String stationSource) {
        this.stationSource = stationSource;
    }

    public List<String> getPhotos() {
        return photos;
    }

    public void setPhotos(List<String> photos) {
        this.photos = photos;
    }

    //public void setTraits(List<String> traits) {
    //    this.traits = traits;
    //}

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public BigDecimal getElecPrice() {
        return elecPrice;
    }

    public void setElecPrice(BigDecimal elecPrice) {
        this.elecPrice = elecPrice;
    }

    public BigDecimal getServicePrice() {
        return servicePrice;
    }

    public void setServicePrice(BigDecimal servicePrice) {
        this.servicePrice = servicePrice;
    }

    public String getIsCollection() {
        return isCollection;
    }

    public void setIsCollection(String isCollection) {
        this.isCollection = isCollection;
    }

    @Override
    public String getServicePhone() {
        return servicePhone;
    }

    @Override
    public void setServicePhone(String servicePhone) {
        this.servicePhone = servicePhone;
    }

    public Integer getIsDisplay() {
        return isDisplay;
    }

    public void setIsDisplay(Integer isDisplay) {
        this.isDisplay = isDisplay;
    }

    public Integer getIsSaas() {
        return isSaas;
    }

    public void setIsSaas(Integer isSaas) {
        this.isSaas = isSaas;
    }

    public String getCollect() {
        return collect;
    }

    public void setCollect(String collect) {
        this.collect = collect;
    }

    public TenantDiscountSearch getMemberSuperLevel() {
        return memberSuperLevel;
    }

    public void setMemberSuperLevel(TenantDiscountSearch memberSuperLevel) {
        this.memberSuperLevel = memberSuperLevel;
    }

    public TenantDiscountSearch getMemberLevelRecord() {
        return memberLevelRecord;
    }

    public void setMemberLevelRecord(TenantDiscountSearch memberLevelRecord) {
        this.memberLevelRecord = memberLevelRecord;
    }

    public TenantDiscountSearch getStationDiscount() {
        return stationDiscount;
    }

    public void setStationDiscount(TenantDiscountSearch stationDiscount) {
        this.stationDiscount = stationDiscount;
    }

    public TenantDiscountSearch getEnterpriseDiscount() {
        return enterpriseDiscount;
    }

    public void setEnterpriseDiscount(TenantDiscountSearch enterpriseDiscount) {
        this.enterpriseDiscount = enterpriseDiscount;
    }

    public TenantDiscountSearch getBestDiscount() {
        return bestDiscount;
    }

    public void setBestDiscount(TenantDiscountSearch bestDiscount) {
        this.bestDiscount = bestDiscount;
    }

    public TenantDiscountSearch getEnterpriseBestDiscount() {
        return enterpriseBestDiscount;
    }

    public void setEnterpriseBestDiscount(TenantDiscountSearch enterpriseBestDiscount) {
        this.enterpriseBestDiscount = enterpriseBestDiscount;
    }

    public BigDecimal getDistance() {
        return distance;
    }

    public void setDistance(BigDecimal distance) {
        this.distance = distance;
    }
}
